package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DtKaohe;
import com.ruoyi.system.service.IDtKaoheService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党员考核Controller
 * 
 * @author ruoyi
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/system/kaohe")
public class DtKaoheController extends BaseController
{
    @Autowired
    private IDtKaoheService dtKaoheService;

    /**
     * 查询党员考核列表
     */
    @PreAuthorize("@ss.hasPermi('system:kaohe:list')")
    @GetMapping("/list")
    public TableDataInfo list(DtKaohe dtKaohe)
    {
        startPage();
        List<DtKaohe> list = dtKaoheService.selectDtKaoheList(dtKaohe);
        return getDataTable(list);
    }

    /**
     * 导出党员考核列表
     */
    @PreAuthorize("@ss.hasPermi('system:kaohe:export')")
    @Log(title = "党员考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DtKaohe dtKaohe)
    {
        List<DtKaohe> list = dtKaoheService.selectDtKaoheList(dtKaohe);
        ExcelUtil<DtKaohe> util = new ExcelUtil<DtKaohe>(DtKaohe.class);
        util.exportExcel(response, list, "党员考核数据");
    }

    /**
     * 获取党员考核详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:kaohe:query')")
    @GetMapping(value = "/{num}")
    public AjaxResult getInfo(@PathVariable("num") String num)
    {
        return success(dtKaoheService.selectDtKaoheByNum(num));
    }

    /**
     * 新增党员考核
     */
    @PreAuthorize("@ss.hasPermi('system:kaohe:add')")
    @Log(title = "党员考核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DtKaohe dtKaohe)
    {
        return toAjax(dtKaoheService.insertDtKaohe(dtKaohe));
    }

    /**
     * 修改党员考核
     */
    @PreAuthorize("@ss.hasPermi('system:kaohe:edit')")
    @Log(title = "党员考核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DtKaohe dtKaohe)
    {
        return toAjax(dtKaoheService.updateDtKaohe(dtKaohe));
    }

    /**
     * 删除党员考核
     */
    @PreAuthorize("@ss.hasPermi('system:kaohe:remove')")
    @Log(title = "党员考核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nums}")
    public AjaxResult remove(@PathVariable String[] nums)
    {
        return toAjax(dtKaoheService.deleteDtKaoheByNums(nums));
    }
}
